package com.ruoyi.base.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.base.domain.BusWaterBussinessitems;
import com.ruoyi.base.service.IBusWaterBussinessitemsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 业务类型对应监测因子Controller
 * 
 * @author ruoyi
 * @date 2025-07-30
 */
@RestController
@RequestMapping("/base/bussinessitems")
public class BusWaterBussinessitemsController extends BaseController
{
    @Autowired
    private IBusWaterBussinessitemsService busWaterBussinessitemsService;

    /**
     * 查询业务类型对应监测因子列表
     */
//    @PreAuthorize("@ss.hasPermi('base:bussinessitems:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusWaterBussinessitems busWaterBussinessitems)
    {
        startPage();
        List<BusWaterBussinessitems> list = busWaterBussinessitemsService.selectBusWaterBussinessitemsList(busWaterBussinessitems);
        return getDataTable(list);
    }

    /**
     * 导出业务类型对应监测因子列表
     */
//    @PreAuthorize("@ss.hasPermi('base:bussinessitems:export')")
//    @Log(title = "业务类型对应监测因子", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusWaterBussinessitems busWaterBussinessitems)
    {
        List<BusWaterBussinessitems> list = busWaterBussinessitemsService.selectBusWaterBussinessitemsList(busWaterBussinessitems);
        ExcelUtil<BusWaterBussinessitems> util = new ExcelUtil<BusWaterBussinessitems>(BusWaterBussinessitems.class);
        util.exportExcel(response, list, "业务类型对应监测因子数据");
    }

    /**
     * 获取业务类型对应监测因子详细信息
     */
    //@PreAuthorize("@ss.hasPermi('base:bussinessitems:query')")
    @GetMapping(value = "/getinfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(busWaterBussinessitemsService.selectBusWaterBussinessitemsById(id));
    }

    /**
     * 新增业务类型对应监测因子
     */
//    @PreAuthorize("@ss.hasPermi('base:bussinessitems:add')")
//    @Log(title = "业务类型对应监测因子", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody BusWaterBussinessitems busWaterBussinessitems)
    {
        return toAjax(busWaterBussinessitemsService.insertBusWaterBussinessitems(busWaterBussinessitems));
    }

    /**
     * 修改业务类型对应监测因子
     */
    //@PreAuthorize("@ss.hasPermi('base:bussinessitems:edit')")
    //Log(title = "业务类型对应监测因子", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody BusWaterBussinessitems busWaterBussinessitems)
    {
        return toAjax(busWaterBussinessitemsService.updateBusWaterBussinessitems(busWaterBussinessitems));
    }

    /**
     * 删除业务类型对应监测因子
     */
//    s
	@GetMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(busWaterBussinessitemsService.deleteBusWaterBussinessitemsByIds(ids));
    }
}
